package com.futao.springbootlearn20220224.aware;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;

/**
 * 获取当前bean的名字
 *
 * @author futao@gmail.com
 * @date 2022/3/9
 */
@Slf4j
@Component("thisIsMyBeanName")
public class BeanNameAwareDemo implements BeanNameAware {

    private String beanName;

    @Override
    public void setBeanName(String name) {
        this.beanName = name;
        log.info("这样就可以获取到当前bean的名字：{}", beanName);
    }
}
